//
// Created by LONG on 2020/10/18.
//

#include <string.h>
#include "../../include/utils/hashFunc.h"

uint32_t Hash_Uint32(void *value)
{
    uint32_t *location;

    location = (uint32_t *)value;

    return (uint32_t)(*location);
}

int32_t Equal_Uint32(void *value1, void *value2)
{
    uint32_t *location1;
    uint32_t *location2;

    location1 = (uint32_t *) value1;
    location2 = (uint32_t *) value2;

    return *location1 == *location2;
}

uint32_t Hash_String(void *string)
{
    uint32_t result;
    unsigned char *p;

    result = 5381;
    p = (unsigned char *)string;
    while (*p != '\0')
    {
        result = (result << 5) + result + *p;
        ++p;
    }

    return result;
}

int32_t Equal_String(void *string1, void *string2)
{
    return strcmp((char *)string1, (char *)string2) == 0;
}
